<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.List" import="java.util.ArrayList" import="org.tobuy.vo.*" import="org.tobuy.factory.*"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
    
    <title>Admin Page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
  <center>
      <%
    	String login = (String)session.getAttribute("login");
    	System.out.println(login);
  		if(login.equals("true")){
		List<Item> items = new ArrayList<Item>();
		List<User> users = new ArrayList<User>();
  		try {
				users = UserDAOFactory.getIUserDAOInstance().findUser();
				items = ItemDAOFactory.getIItemDAOInstance().findItems();
				
			} catch (Exception e) {
				e.printStackTrace();
			}
		Iterator<Item> itemIter = items.iterator();
		Iterator<User> userIter = users.iterator();
		
		
		
   %>
   	<h2>Welcome Admin, <a href="admin_logout.jsp">Logout</a></h2>
  	<h3>Registrated User in plattform</h3>
   	<table border=1>
   		<tr>
   			<td>User ID:</td>
   			<td>User Name:</td>
   			<td>Delete</td>
   		</tr>
   		<%
   			while(userIter.hasNext()){
   				User user = userIter.next();
   				%>
   				<tr>
   				<td><%=user.getUser_id() %></td>
   				<td><%=user.getUser_name() %></td>
   				<td><a href="AdminDelete?id=<%=user.getUser_id() %>&type=user">Delete</a></td>
   				</tr>
   				<%
   			}
   		 %>
   	</table>
   	<h3>Stuffs on Sell in plattform</h3>
   	<table border=1>
   		<tr>
   			<td>Item ID:</td>
   			<td>Item Name:</td>
   			<td>Delete</td>
   		</tr>
   		<%
   			while(itemIter.hasNext()){
   				Item item = itemIter.next();
   				%>
   				<tr>
   				<td><%=item.getItem_id() %></td>
   				<td><%=item.getItem_name() %></td>
   				<td><a href="AdminDelete?id=<%=item.getItem_id() %>&type=item">Delete</a></td>
   				</tr>
   				<%
   			}
   		 %>
   	</table>
   	<%}else{ %>
   		<h2>Please login as Admin!</h2>
   	<%} %>
   	</center>
  </body>
</html>
